﻿using System;
using System.Xml;

namespace Mbs.Configuration
{
    [Serializable]
    public class XmlConfiguration : Node
    {
        
        public XmlConfiguration(string name, string value)
            : base()
        {
            this.internalName = name;
            this.internalValue = value;
        }

       
        public XmlConfiguration(XmlNode node)
            : base(StringComparer.OrdinalIgnoreCase)
        {
            this.internalName = node.LocalName;
            this.internalValue = node.InnerText;

            if (node.Attributes != null)
                foreach (XmlAttribute attr in node.Attributes)
                {
                    Attributes.Set(attr.LocalName, attr.InnerText);
                }

            foreach (XmlNode child in node.ChildNodes)
            {
                if (child.NodeType != XmlNodeType.Element)
                    continue;

                Nodes.Add(new XmlConfiguration(child));
            }
        }
    }
}
